<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>查询</title>
  <!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
  <script src="libs/jquery-1.12.1.min.js"></script>
  <link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
  <script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
  <script src="libs/handlebars.min.js"></script>
  <script src="libs/getQueryString.js"></script>
   <script src="libs/js.cookie-2.1.0.min.js"></script>
</head>
<body>
<div class="container">
    <div class="row">
  <div class="page-header"><h2><strong>周三记账</strong></h2></div>
    </div>
</div>
<div class="container">
  <div class="row">
  <div class="col-md-12">
    <ul class="nav nav-pills">
    <li > <a href="index.html">首页</a></li>
    <li > <a href="in.html">新加收入</a></li>
    <li > <a href="out.html">新加支出</a></li>
    <li class="active"> <a href="#"> 查询</a></li>
    <li> <a href="query.html"> 统计</a></li>
    <li > <a href="#">用户：<span id="text3"></span></a></li>
    <li> <a id="exit"> 退出</a></li>
    </ul>
  </div>
  </div>
</div>
      <div class="container">
<div class="row">
      <div class="col-md-12">
        <div class="panel panel-primary">
          <div class="panel-heading">查询记录</div>
          <div class="panel-body" id="list1"></div>
         
        </div>
      </div>
    </div>
</div>
<script id="template" type="text/x-handlebars-template">
{{#each item}}
<div class="panel panel-default col-md-3">
  <div class="panel-body">
   <dl>
     <dt>时间</dt> <dd>{{date_time}}</dd>
     <dt>地点</dt> <dd>{{place}}</dd>
    <dt>收入金额</dt> <dd>{{money_in}}</dd>
    <dt>支出金额</dt> <dd>{{money_in}}</dd>
    <dt>类别</dt> <dd>{{kind}}</dd>
    <dt>备注</dt> <dd>{{money_in}}</dd>
    <button id="del" >删除</button>
   </dl>
 </div>
</div>
{{/each}}
</script>
  <script type="text/javascript">
 $(function () {
	 
	 $('#exit').click(function () {
	      $.post('exit.action', {
	        
	      }, function (res, status) {
	        if ('OK' == res) {
	          alert('退出成功'); window.location.href='login.html';
	        } else if ('ERR' == res) {
	          alert('账号或密码错误');
	          
	        }
	        
	      });
	    });
	 
	 
	var id=getQueryString("id");
	  $.getJSON('querymore.action?id='+id,function(res){
			 
			 var data = {'item':res};
			var t = Handlebars.compile($('#template').html());
			$('#list1').html(t(data)); 
			
			
			$('#del').click(function () {
				 
			      $.post('del.action', {
			    	  id: id
			      }, function (res, status) {
			        if ('OK' == res) {
			          alert('删除成功'); window.location.href='chaxun.html';
			        } else if ('ERR' == res) {
			          alert('账号或密码错误');}
			        });
			    });
			
			
		 });
	       
	  
	   
 });
  </script>
<script type="text/javascript">
if (!Cookies.get("user")){
	window.location.href='login.html';
}
</script>
</body>
</html>